package cn.itcast.user.controller;

import cn.itcast.hmall.pojo.user.User;
import cn.itcast.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserMapper userMapper;

    @GetMapping("/{id}")
    public User findById(@PathVariable Long id) {
        User user = userMapper.selectById(id);
        return user;
    }
    @PutMapping
    public boolean update(@RequestBody User user){
        int i = userMapper.updateById(user);
        if (i!=0){
            return true;
        }
        return false;
    }
}
